package com.sgb.kjwl.view.ui.activity.manage;

import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.GridLayoutManager;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.amap.api.maps.MapView;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.Marker;
import com.androidkun.xtablayout.XTabLayout;
import com.sgb.alimaplibrary.MapMarkerTools;
import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivityEnterpriseAndMapBinding;
import com.sgb.kjwl.interfaces.RecyclerClick;
import com.sgb.member.MemberConfig;
import com.swgk.core.base.aroute.AppRouteConstant;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.kjwl.model.entity.TwoLevelChildForPopWindowEntity;
import com.sgb.kjwl.model.entity.TwoLevelForPopWindowEntity;
import com.sgb.kjwl.model.entity.enterprise.IpPickSelectEntity;
import com.sgb.kjwl.model.entity.manage.TheEnterpriseOfEntity;
import com.sgb.kjwl.utils.DialogFunction;
import com.sgb.kjwl.utils.DialogHelper;
import com.swgk.core.event.EventConstant;
import com.sgb.link.event.MaterialEvent;
import com.sgb.kjwl.view.ui.activity.self.userInfo.VerificationCodeLoginActivity;
import com.sgb.kjwl.view.ui.adapter.manage.RecommendedEnterprisesAdapter;
import com.sgb.kjwl.view.widget.ActionBar;
import com.sgb.kjwl.view.widget.EnterprisePopWindow;
import com.sgb.kjwl.view.widget.IpPopWindow;
import com.sgb.kjwl.view.widget.MapInfoDialog6;
import com.sgb.kjwl.view.widget.MapInfoWindow6;
import com.sgb.kjwl.view.widget.ThreeLevelAreaWindow;
import com.sgb.kjwl.view.widget.TwoLevelEntityPopWindow;
import com.sgb.kjwl.viewmodel.manage.EnterpriseAndMapModel;
import com.swgk.core.base.BaseViewModel;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.helper.OnMultiClickListener;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;
import com.swgk.core.recyclerview.entity.BaseAreaEntity;
import com.swgk.core.xrecyclerview.XRecyclerView;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Route(path = AppRouteConstant.EnterpriseAndMapActivity)
public class EnterpriseAndMapActivity extends AppActivity {

    EnterpriseAndMapModel model;
    private ActivityEnterpriseAndMapBinding binding;
    private String longitude,latitude,mIntroduction,type,text, areaCode = "", cityNos = "",price,dic = "",mOneLevelNo = "",mTwoLevelNo = "",name1 = "",name2 = ""
            ,name3 = "",mMapTitle = "";
    private IpPopWindow homeGoodsSelectionTypePopWindow;
    private List<PickSelectEntity<List<PickSelectEntity>>> list;
    private boolean mIsLoadMore,isList,isMap;
    private int mPage,mPosition,lastPosition,mFollowType;
    private TheEnterpriseOfEntity entity;
    private RecommendedEnterprisesAdapter recommendedEnterprisesAdapter;
    private ThreeLevelAreaWindow theEnterpriseOfAreaPopWindow;//省市弹窗
    private EnterprisePopWindow moneyPopWindow,distancePopWindow;
    private List<PickSelectEntity> typeData2 = new ArrayList<>(),distanceData = new ArrayList<>();
    private List<TheEnterpriseOfEntity> mapList = new ArrayList<>();//地图数据

    public MapMarkerTools mapMarkerTools;
    private Marker markerLast;

    private MapInfoDialog6 mapInfoDialog6;
    private TwoLevelEntityPopWindow<TwoLevelForPopWindowEntity> typePopWindow;//分类弹窗

    public static void start(Context context, String longitude, String latitude, boolean isMap) {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putString("longitude", longitude);
        bundle.putString("latitude", latitude);
        bundle.putBoolean("isMap", isMap);
        intent.putExtras(bundle);
        intent.setClass(context, EnterpriseAndMapActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        context.startActivity(intent);
    }

    @Override
    protected boolean statusBarDark() {
        return false;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        isMap = getIntent().getBooleanExtra("isMap", false);
        if (isMap) {
            mActionBar.setTitle("地图查找");
            mActionBar.setTitleVisible(false);
            mActionBar.setEditVisible(false);
            mActionBar.setMenuFunctionVisible(false);
        }

        if (isMap) {
            binding.mapView.setVisibility(View.VISIBLE);
            binding.recyclerView.setVisibility(View.GONE);
            mapMarkerTools = new MapMarkerTools(getActivity(), getLifecycle());
            initMap(savedInstanceState);
        } else {
            binding.recyclerView.setVisibility(View.VISIBLE);
            binding.mapView.setVisibility(View.GONE);
        }

        mActionBar.setMenuFunctionClick(new OnMultiClickListener() {
            @Override
            public void onMultiClick(View v) {
                text = mActionBar.getEditText();
                loadComData(false);
            }
        });

        mActionBar.setClearEdiText(new ActionBar.ClearEdiText() {
            @Override
            public void clearEdiText() {
                text = "";
                loadComData(false);
            }

            @Override
            public void search() {
                closeKeybord();
                loadComData(false);
            }
        });
    }

    @Override
    protected void initView() {
        super.initView();
        binding = DataBindingUtil.setContentView(EnterpriseAndMapActivity.this, R.layout.activity_enterprise_and_map);
        binding.setViewModel(new BaseViewModel());
        longitude = getIntent().getStringExtra("longitude");
        latitude = getIntent().getStringExtra("latitude");

        binding.setLifecycleOwner(this);
        model = new ViewModelProvider(this).get(EnterpriseAndMapModel.class);

        binding.editView.setOnClickListener(this);

        homeGoodsSelectionTypePopWindow = new IpPopWindow(this);
        homeGoodsSelectionTypePopWindow.setDefItem(0);
        homeGoodsSelectionTypePopWindow.setBgView(binding.grayLayout);

        homeGoodsSelectionTypePopWindow.setOnResultClick((key1, key2, key3) -> {
            binding.tabLayout.getTabAt(((int) key2)).select();
            binding.editView.setImageResource(R.mipmap.btn_expand1);
        });
        homeGoodsSelectionTypePopWindow.setOnDismissListener(() -> binding.editView.setImageResource(R.mipmap.btn_expand1));

        EventBus.getDefault().postSticky(this);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }

        initTabLayout();
        initLiveData();
        initButton();
        initRecycleView();
        initSelect();
    }

    private void initTabLayout(){
        binding.tabLayout.addOnTabSelectedListener(new XTabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(XTabLayout.Tab tab) {
                mIntroduction = list.get(tab.getPosition()).getNo();
                loadComData(false);
            }

            @Override
            public void onTabUnselected(XTabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(XTabLayout.Tab tab) {

            }
        });

        binding.tlCompanyTradesType.addOnTabSelectedListener(new XTabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(XTabLayout.Tab tab) {
                type = typeData2.get(tab.getPosition()).getNo();
                loadComData(false);
            }

            @Override
            public void onTabUnselected(XTabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(XTabLayout.Tab tab) {

            }
        });
    }

    private void initButton(){
        binding.tvDistance.setOnClickListener(this);
        binding.tvArea.setOnClickListener(this);
        binding.tvType.setOnClickListener(this);
        binding.tvPersonNumber.setOnClickListener(this);
    }

    private void showTypePop(){
        List<IpPickSelectEntity> dictData = new ArrayList<>();
        for (PickSelectEntity oneDatum : list) {
            IpPickSelectEntity menuEntity = new IpPickSelectEntity(oneDatum.getNo(), oneDatum.getProjectscale(),"","","","","");
            dictData.add(menuEntity);
        }
        homeGoodsSelectionTypePopWindow.showPopwindow(binding.rlTop, 0,0);
        homeGoodsSelectionTypePopWindow.setData(dictData);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.edit_view:
                showTypePop();
                binding.editView.setImageResource(R.mipmap.btn_expand_up_gray);
                break;
            case R.id.tv_area:
                binding.tvArea.contentSelect(false, true);
                showProvincePopWindow();
                break;
            case R.id.tv_person_number:
                binding.tvPersonNumber.contentSelect(false, true);
                showPerson();
                break;
            case R.id.tv_distance:
                binding.tvDistance.contentSelect(false, true);
                showDistancePopWindowPopWindow();
                break;
            case R.id.tv_type:
                binding.tvType.contentSelect(false, true);
                showType();
                break;
        }
    }

    @Override
    protected void init() {
        super.init();
        model.getCityData(EnterpriseAndMapActivity.this);
        model.getTradeTypes(EnterpriseAndMapActivity.this);
        model.getType(EnterpriseAndMapActivity.this);
        model.findCapitalList(EnterpriseAndMapActivity.this);
        model.getDistanceDatas();
        model.getTypeList(EnterpriseAndMapActivity.this);
    }

    private void initRecycleView() {
        //列表
        if (recommendedEnterprisesAdapter == null) {
            recommendedEnterprisesAdapter = new RecommendedEnterprisesAdapter(getActivity(), null);
        }
        binding.recyclerView.setLayoutManager(new GridLayoutManager(getActivity(), 1));
        binding.recyclerView.setAdapter(recommendedEnterprisesAdapter);
        recommendedEnterprisesAdapter.setOnItemClick(new AdapterOnItemClick<TheEnterpriseOfEntity>() {
            @Override
            public void onItemClick(TheEnterpriseOfEntity entity, int position) {
                if (!TextUtils.isEmpty(entity.getSupplier())){
                    WebsiteInfoActivity.start(getActivity(),entity.getSupplier(),1);
                }else {
                    Toast.makeText(getActivity(), "公司no为空", Toast.LENGTH_SHORT).show();
                }
            }
        });

        recommendedEnterprisesAdapter.setmRecyclerClick(new RecyclerClick<TheEnterpriseOfEntity>() {
            @Override
            public void followClick(TheEnterpriseOfEntity entity) {
                mFollowType = 0;
                if (DialogHelper.checkLogin()){
                    if (entity.getFollow()){
                        DialogHelper.showDialog(EnterpriseAndMapActivity.this, "提示", "确定取消关注该企业？", "取消关注", new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {
                                model.follow(entity.getSupplier(),EnterpriseAndMapActivity.this);
                            }
                        });
                    }else {
                        model.follow(entity.getSupplier(),EnterpriseAndMapActivity.this);
                    }
                }else {
                    VerificationCodeLoginActivity.start(EnterpriseAndMapActivity.this, EventConstant.EVENT_MANAGE);
                }
            }
        });

        binding.recyclerView.setLoadingMoreEnabled(true);
        binding.recyclerView.setLoadingListener(new XRecyclerView.LoadingListener() {
            @Override
            public void onRefresh() {
                loadComData(false);
            }

            @Override
            public void onLoadMore() {
                loadComData(true);
            }
        });

    }

    private void initSelect(){
        typePopWindow = new TwoLevelEntityPopWindow<>(getActivity());
        typePopWindow.setBgView(binding.grayLayout);
        typePopWindow.setmTwoLevelClick(new TwoLevelEntityPopWindow.TwoLevelClick<TwoLevelForPopWindowEntity>() {
            @Override
            public void oneClick(TwoLevelChildForPopWindowEntity<List<TwoLevelForPopWindowEntity>> d, int position) {
                name3 = d.getName();
                if (!mOneLevelNo.equals(d.getId())){
                    mTwoLevelNo = "";
                }
                mOneLevelNo = d.getId();
            }

            @Override
            public void twoClick(TwoLevelForPopWindowEntity twoLevelEntityForPopWindow, int position) {
                name3 = twoLevelEntityForPopWindow.getName();
                mTwoLevelNo = twoLevelEntityForPopWindow.getId();
            }

            @Override
            public void reset() {
                typePopWindow.dismiss();
                loadComData(false);
            }
        });

        typePopWindow.setOnResultClick((key1, key2, key3) -> loadComData(false));
        typePopWindow.setOnDismissListener(() -> binding.tvType.contentSelect(!name3.equals("不限") && !name3.equals(""), false));

        // 省 城市
        theEnterpriseOfAreaPopWindow = new ThreeLevelAreaWindow(getActivity()){
            @Override
            protected void provinceClick(BaseAreaEntity baseAreaEntity, int position) {
                super.provinceClick(baseAreaEntity, position);
                name1 = baseAreaEntity.getSimpleName();
                if (!areaCode.equals(baseAreaEntity.getId())){
                    cityNos = "";
                }
                areaCode = baseAreaEntity.getId();
            }

            @Override
            protected void cityClick(BaseAreaEntity baseAreaEntity, int position) {
                super.cityClick(baseAreaEntity, position);
                cityNos = baseAreaEntity.getId();
                name1 = baseAreaEntity.getSimpleName();
            }

            @Override
            protected void reset() {
                super.reset();
                theEnterpriseOfAreaPopWindow.dismiss();
                loadComData(false);
            }
        };
        theEnterpriseOfAreaPopWindow.setBgView(binding.grayLayout);
        theEnterpriseOfAreaPopWindow.setThreeListIsGone(true);
        theEnterpriseOfAreaPopWindow.setProvinceSingle();
        theEnterpriseOfAreaPopWindow.setCitySingle();
        theEnterpriseOfAreaPopWindow.setOnResultClick((key1, key2, key3) -> loadComData(false));
        theEnterpriseOfAreaPopWindow.setOnDisMissClick(() -> {
            binding.tvArea.contentSelect(!name1.equals("") && (!name1.equals("不限")), false);
            if (areaCode.equals("")) {
                binding.tvArea.contentSelect(false, false);
            }
        });

        // 注册资金
        moneyPopWindow = new EnterprisePopWindow(getActivity());
        moneyPopWindow.setBgView(binding.grayLayout);
        moneyPopWindow.setOnResultClick(new BasePopWindow.OnResultClick() {
            @Override
            public void result(Object key1, Object key2, Object key3) {
                price = (String) key1;
                name2 = (String) key2;
                //请求接口
                loadComData(false);
            }
        });
        moneyPopWindow.setOnDisMissClick(() -> binding.tvPersonNumber.contentSelect(!name2.equals("") && !name2.equals("不限"), false));
        // 距离
        distancePopWindow = new EnterprisePopWindow(getActivity());
        distancePopWindow.setBgView(binding.grayLayout);
        distancePopWindow.setOnResultClick((key1, key2, key3) -> {
            try {
                String distance = (String) key1;
                if (!distance.equals("")){
                    dic = Long.valueOf(distance) * 1000 + "";
                }else {
                    dic = distance;
                }
                name3 = (String) key2;
                //请求接口
                loadComData(false);
            } catch (Exception e) {
                Toast.makeText(getActivity(), "您输入的数字太大", Toast.LENGTH_SHORT).show();
            }
        });
        distancePopWindow.setOnDisMissClick(() -> binding.tvDistance.contentSelect(!name3.equals("") && !name3.equals("不限"), false));
    }

    private void showProvincePopWindow() {
        theEnterpriseOfAreaPopWindow.showPopwindow(binding.llTop,0,0);
    }

    private void showDistancePopWindowPopWindow() {
        distancePopWindow.showPopwindow(binding.llTop,0,0);
    }

    private void addMarkInfoWindow(List<TheEnterpriseOfEntity> datas) {
        try {
            mapMarkerTools.mapClear();
            mapList.clear();
            if (datas.size() == 0) {
                Toast.makeText(getActivity(), "暂无数据", Toast.LENGTH_SHORT).show();
                return;
            }
            for (int i = 0; i < datas.size(); i++) {
                datas.size();
                TheEnterpriseOfEntity entity = datas.get(i);
                if (null != entity && !TextUtils.isEmpty(entity.getLatitude()) && !TextUtils.isEmpty(entity.getLongitude())) {
                    double currentLat = Double.parseDouble(entity.getLatitude());
                    double currentLong = Double.parseDouble(entity.getLongitude());
                    if (currentLat != 0 && currentLong != 0) {
                        mapMarkerTools.addPoiItem(currentLat, currentLong, "");
                        mapList.add(datas.get(i));
                    }
                }
            }
            mapMarkerTools.addAllMarkerToMap(0, true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    private void initMap(Bundle savedInstanceState) {
        MapView mMapView = binding.mapView;
        mapMarkerTools.init(savedInstanceState, mMapView);
        mapMarkerTools.setMarkerClick(new MapMarkerTools.MarkerClick() {
            @Override
            public void onMarkerClick(int pos, String title) {
            }

            @Override
            public void onMarkerClick(int pos, String title, Marker marker) {
                mMapTitle = title;
                showMarkerView(pos, title);
                BitmapDescriptor bitmapSmall = BitmapDescriptorFactory.fromView(setMarkStyle(Integer.valueOf(title), marker, true));
                marker.setIcon(bitmapSmall);
                resetMarker(marker.getId(), marker, pos);
                mPosition = pos;
                markerLast = marker;
                lastPosition = Integer.valueOf(title);
                mapMarkerTools.jumpPoint(marker);
            }

            @Override
            public void onLocationChanged(Double currentLat, Double currentLong, String address) {

            }
        });
    }

    private View setMarkStyle(int pos, Marker marker, boolean isBigMarkView) {
        View markerView = LayoutInflater.from(getActivity()).inflate(com.sgb.alimaplibrary.R.layout.view_marker, null);
        ImageView imageView = markerView.findViewById(com.sgb.alimaplibrary.R.id.marker);
        TextView textView = markerView.findViewById(com.sgb.alimaplibrary.R.id.text);
        textView.setText(pos + 1 + "");
        Drawable drawable = getResources().getDrawable(isBigMarkView ? com.sgb.alimaplibrary.R.drawable.marker_big : com.sgb.alimaplibrary.R.drawable.marker);
        int smallFontSize = (int) getResources().getDimension(com.sgb.alimaplibrary.R.dimen.sp5);
        int bigFontSize = (int) getResources().getDimension(com.sgb.alimaplibrary.R.dimen.sp8);
        textView.setTextSize(isBigMarkView ? bigFontSize : smallFontSize);
        imageView.setImageDrawable(drawable);
        return markerView;
    }

    private void resetMarker(String curMarkerId, Marker markerNew, int pos) {
        if (null != markerLast) {
            if (!TextUtils.equals(curMarkerId, markerLast.getId())) {
                markerLast.setIcon(BitmapDescriptorFactory.fromView(setMarkStyle(lastPosition, markerLast, false)));
            }
        }
    }

    public boolean showMarkerView(int pos, String title) {
        entity = mapList.get(Integer.valueOf(title));
        MapInfoWindow6 mapInfoWindow = new MapInfoWindow6(getActivity());
        mapInfoWindow.setData(entity);
        mapInfoDialog6 = new MapInfoDialog6(getActivity(), null);
        mapInfoDialog6.getWindow().setDimAmount(0f);
        mapInfoDialog6.setDialogClickCallBack(new MapInfoDialog6.DialogClickCallBack() {
            @Override
            public void onClickShop(String shopId) {
                if (!TextUtils.isEmpty(shopId)){
                    WebsiteInfoActivity.start(getActivity(),shopId,1);
                }else {
                    Toast.makeText(getActivity(), "公司no为空", Toast.LENGTH_SHORT).show();
                }
            }

            @Override
            public void onClickFollow(TheEnterpriseOfEntity entity) {
                mFollowType = 1;
                if (DialogHelper.checkLogin()){
                    if (entity.getFollow()){
                        DialogHelper.showDialog(EnterpriseAndMapActivity.this, "提示", "确定取消关注该企业？", "取消关注", new DialogFunction() {
                            @Override
                            public void normalRoundDialog() {
                                model.follow(entity.getSupplier(),EnterpriseAndMapActivity.this);
                            }
                        });
                    }else {
                        model.follow(entity.getSupplier(),EnterpriseAndMapActivity.this);
                    }
                }else {
                    VerificationCodeLoginActivity.start(EnterpriseAndMapActivity.this, EventConstant.EVENT_MANAGE);
                }
            }
        }).setData(mapInfoWindow.getData()).show();
        return false;
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    private void showType(){
        typePopWindow.showPopwindow(binding.llTop,0,0);
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventBus(MaterialEvent event) {
        if (event.getMessageTag() == EventConstant.EVENT_MANAGE) {
            loadComData(false);
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        loadComData(false);
    }

    private void initLiveData(){
        model.mCom.observe(this, theEnterpriseOfEntities -> {
            if (!isMap) {
                binding.recyclerView.refreshComplete();
                if (mIsLoadMore) {
                    if (null != theEnterpriseOfEntities && theEnterpriseOfEntities.size() > 0) {
                        binding.recyclerView.loadMoreComplete();
                        recommendedEnterprisesAdapter.addDatas(theEnterpriseOfEntities);
                    } else {
                        binding.recyclerView.setNoMore(true);
                    }
                    binding.recyclerView.setVisibility(View.VISIBLE);
                } else {
                    binding.recyclerView.refreshComplete();
                    if (null != theEnterpriseOfEntities && theEnterpriseOfEntities.size() > 0) {
                        binding.recyclerView.setVisibility(View.VISIBLE);
                        binding.emptyView.setVisibility(View.GONE);
                        recommendedEnterprisesAdapter.setDatas(theEnterpriseOfEntities);
                        binding.recyclerView.setLoadingMoreEnabled(true);
                    } else {
                        recommendedEnterprisesAdapter.setDatas(null);
                        binding.recyclerView.setVisibility(View.GONE);
                        binding.emptyView.setVisibility(View.VISIBLE);
                    }
                }
            } else {
                addMarkInfoWindow(theEnterpriseOfEntities);
            }
        });

        model.mDistance.observe(this, pickSelectEntities -> {
            distanceData.clear();
            distanceData.addAll(pickSelectEntities);
            distancePopWindow.setData(distanceData, true, false);
        });

        model.mCapital.observe(this, pickSelectEntities -> {
            moneyPopWindow.setData(pickSelectEntities);
        });

        model.mCity.observe(this, addressEntities -> {
            theEnterpriseOfAreaPopWindow.setDataForCompany(addressEntities, true);
        });

        model.mFollow.observe(this, aBoolean -> {
            if (mFollowType == 1){
                mapInfoDialog6.updateText();

                entity.setFollow(!(entity.getFollow()));
                mapList.get(Integer.parseInt(mMapTitle)).setFollow(!(mapList.get(Integer.parseInt(mMapTitle)).getFollow()));
                resetMarker(markerLast.getId(), markerLast, mPosition);
            }else {
                loadComData(false);
            }
        });

        model.mTradeType.observe(this, twoLevelChildForPopWindowEntities -> typePopWindow.setData(twoLevelChildForPopWindowEntities));

        model.mType.observe(this, pickSelectEntities -> {
            typeData2 = pickSelectEntities;
            for (PickSelectEntity data : pickSelectEntities) {
                binding.tlCompanyTradesType.addTab(binding.tlCompanyTradesType.newTab().setText(data.getPickerViewText()));
            }
        });

        model.mTypeFirst.observe(this, pickSelectEntities -> {
            list = pickSelectEntities;
            for (PickSelectEntity<List<PickSelectEntity>> pickSelectEntity : pickSelectEntities) {
                binding.tabLayout.addTab(binding.tabLayout.newTab().setText(pickSelectEntity.getPickerViewText()));
            }
        });
    }

    private void showPerson(){
        moneyPopWindow.showPopwindow(binding.llTop,0,0);
    }

    private void loadComData(boolean isLoadMore){
        Map<String, Object> map = new HashMap<>();
        this.mIsLoadMore = isLoadMore;
        mPage = !isLoadMore ? 1 : mPage+1;
        map.put("page",mPage);
        map.put("limit","20");
        map.put("industryCategory2", mTwoLevelNo);
        map.put("industryCategory1", mOneLevelNo);
        map.put("areaNo", cityNos);
        map.put("provinceNo", areaCode);
        map.put("staffNumber", price);
        map.put("distance", dic);
        map.put("dictId", type);
        map.put("longitude", longitude);
        map.put("latitude", latitude);
        if (isMap) {
            map.put("distance", "1000000000");
        } else {
            map.put("onMap", "0");
        }
        map.put("name", text);
        map.put("serviceType",mIntroduction);
        model.getComList(map,EnterpriseAndMapActivity.this);
    }
}
